Skip to content

feat: lake: separate leanir job - #14906

Open
tydeu wants to merge 3 commits into
leanprover:masterfrom
tydeu:lake/ir-arts
Open

feat: lake: separate leanir job #14906
tydeu wants to merge 3 commits into
leanprover:masterfrom
tydeu:lake/ir-arts

Conversation

@tydeu

@tydeu tydeu commented Aug 24, 2026

Copy link
Copy Markdown
Member

This PR splits leanir into a separate Lake job and target.

When the Lean option compiler.postponeCompiler is enabled, only *.olean files are produced by the initial Lean elaboration. Code generation then occurs in a subsequent irArts job that calls leanir to emit .c and .ir / .ir.sig files for the module. This job traces the .ir.sig files of the import graph and only rebuilds when they change. Postponed compilation in irArts does not yet make use of the Lake artifact cache. That will need a follow-up PR.

Because #eval in the serve needs IR and Lake does not currently distinguish between server and CLI builds, all module elaboration still waist for the IR of there imports to be built. However, this now more clearly demarcated in the code by fetchExportInfo and could evolve in the future if a separate serverExportInfo is developed.

A test of postponed compilation is added as moduleCodegen.

Split from #13169.

@tydeu tydeu added the changelog-lake Lake label Aug 24, 2026
tydeu and others added 2 commits August 28, 2026 23:26
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions github-actions Bot added toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN labels Aug 28, 2026
@leanprover-bot leanprover-bot added the breaks-manual This is not necessarily a blocker for merging, but there needs to be a plan. label Aug 28, 2026
@leanprover-bot

leanprover-bot commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Aug 29, 2026
@mathlib-lean-pr-testing

mathlib-lean-pr-testing Bot commented Aug 29, 2026

Copy link
Copy Markdown

Mathlib CI status (docs):

mathlib-nightly-testing Bot pushed a commit to leanprover-community/batteries that referenced this pull request Aug 29, 2026
mathlib-nightly-testing Bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Aug 29, 2026
leanprover-bot added a commit to leanprover/reference-manual that referenced this pull request Aug 29, 2026
mathlib-nightly-testing Bot pushed a commit to leanprover-community/batteries that referenced this pull request Aug 29, 2026
mathlib-nightly-testing Bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Aug 29, 2026
leanprover-bot added a commit to leanprover/reference-manual that referenced this pull request Aug 29, 2026
@tydeu
tydeu marked this pull request as ready for review August 29, 2026 03:14
@tydeu
tydeu requested a review from Kha August 29, 2026 03:15
Comment thread src/LeanIR.lean
Comment on lines +94 to +96
-- As the environment imports the module to compile, it does not inherit its package.
-- Take it from the setup.
let env := env.setModulePackage setup.package?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kha This changes non-Lake code and is thus probably the bit that most needs your review.

Comment on lines +396 to +424
let info := {info with
irSigTrace :=
if nonModule || imp.importAll then
info.irSigTrace
|>.mix expInfo.allTransTrace
|>.mix expInfo.allArtsTrace.withoutInputs
else
info.irSigTrace
|>.mix expInfo.irSigTransTrace
|>.mix expInfo.irSigArtsTrace.withoutInputs
}
if imp.isExported then
if imp.isMeta then
{info with
transTrace := info.transTrace
{info with
transTrace :=
if imp.isMeta then
info.transTrace
|>.mix expInfo.metaTransTrace
|>.mix expInfo.metaArtsTrace.withoutInputs
|>.withoutInputs
}
else
{info with
transTrace := info.transTrace
else
info.transTrace
|>.mix expInfo.transTrace
|>.mix expInfo.artsTrace.withoutInputs
|>.withoutInputs
}
irSigTransTrace := info.irSigTransTrace
|>.mix expInfo.irSigTransTrace
|>.mix expInfo.irSigArtsTrace.withoutInputs
|>.withoutInputs
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kha This code here (outside transTrace) is the new trace code. It could also use your review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaks-manual This is not necessarily a blocker for merging, but there needs to be a plan. builds-mathlib CI has verified that Mathlib builds against this PR changelog-lake Lake mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants